package cn.coisini.model.common.ai.service.impl;

import cn.coisini.model.common.ai.service.DeepSeekService;
import cn.coisini.model.common.dtos.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.messages.UserMessage;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;

/**
 * @author xiangshaw
 * Description: DeepSeek服务实现类
 */
@Service
@RequiredArgsConstructor
public class DeepSeekServiceImpl implements DeepSeekService {

    private final OpenAiChatModel openAiChatModel;

    @Override
    public Result<String> chat(String message) {
        return Result.ok(openAiChatModel.call(message));
    }


    @Override
    public Result<Flux<ChatResponse>> chatFlux(String message) {
      return Result.ok(openAiChatModel.stream(new Prompt(new UserMessage(message))));
    }
}
